package com.wpl.controller;


import com.wpl.bean.Workorder;
import com.wpl.common.WebResponse;
import com.wpl.service.IWorkorderService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

@RestController
@RequestMapping("/workorder/")
public class WorkorderController {

    @Resource
    private IWorkorderService workorderService;

    @GetMapping("/list")
    public WebResponse findAll(){


        List<Workorder> workorderList = workorderService.findAll();
        return WebResponse.success(workorderList);
    }

    @PostMapping("/insert")
    public WebResponse getData(@RequestBody Workorder workorder){
        workorder.setOrderid("bank"+new Date().getTime());
        System.out.println("----------"+workorder);
        int count = workorderService.insert(workorder);
        if(count>0){
            return WebResponse.success(count);
        }else {
            return WebResponse.failed();
        }

    }
}
